package com.example.yuejian.yuejian.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.yuejian.yuejian.R;
import com.example.yuejian.yuejian.adapter.MyFollowAdapter;
import com.example.yuejian.yuejian.base.BaseActivity;
import com.example.yuejian.yuejian.base.ModleListListener;
import com.example.yuejian.yuejian.bean.MyFollowMaster;
import com.example.yuejian.yuejian.model.UserModel;

import java.util.List;


public class MyFollowActivity extends BaseActivity  {
 /*   private SwipeRefreshLayout swipeRefreshLayout;
    private MyFollowAdapter adapter;
    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 0x101:
                    if (swipeRefreshLayout.isRefreshing()){
                        adapter.notifyDataSetChanged();
                        swipeRefreshLayout.setRefreshing(false);//设置不刷新
                    }
                    break;
            }
        }
    };*/

    private RecyclerView recyclerView;

    private ImageView btn_back;
    List<MyFollowMaster> list;
    private ModleListListener<MyFollowMaster> modleListListener=new ModleListListener<MyFollowMaster>() {
        @Override
        public void onResponse(List<MyFollowMaster> l) {
            list=l;
            recyclerView.setAdapter(new MyFollowAdapter(getApplication(),list));

        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(getApplication(),"fail:"+msg,Toast.LENGTH_SHORT).show();
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_follow);
        initViews();

        back();
        /*swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light,
                android.R.color.holo_orange_light, android.R.color.holo_red_light);

        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                new LoadDataThread().start();
            }
        });*/
    }
    private void initViews()
    { recyclerView=(RecyclerView)findViewById(R.id.my_follow_recycleview);
        // GridLayoutManager gm = new GridLayoutManager(this.getActivity(),2);
        // 网格是的list布局   2列
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        //recyclerView.setLayoutManager(gm);
      //swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.main_srl);
       /* footerView = getLayoutInflater().inflate(R.layout.loading_layout,null);
        recyclerView.addFooterView(footerView);

        recyclerView.setOnScrollListener(this);*/

    }
    private  void getData()
    {
        UserModel userModel=new UserModel();
        userModel.MyfollowList(getUser_id(),modleListListener);

    }
    private void back()
    {
        btn_back=(ImageView)findViewById(R.id.imgBtn_myfollow_back);
        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

    }
    public void onResume() {
        getData();
        super.onResume();

    }





}
